package com.robam.cloud.usercenter.controller;


import com.robam.cloud.common.bean.restful.entity.RespMsg;
import com.robam.cloud.common.bean.usercenter.form.RealNameForm;
import com.robam.cloud.log.annotation.OperationLogRecord;
import com.robam.cloud.restful.config.realcheck.annotation.CheckRealUser;
import com.robam.cloud.usercenter.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Api("用户控制类")
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;
    @Autowired
    HttpServletRequest httpServletRequest;

    @ApiOperation(
            value = "实名更新",
            notes = "实名更新")
    @OperationLogRecord(
            describe = "实名更新",
            modularCode = "/user/realName",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/realName",
            method = RequestMethod.POST)
    public RespMsg realName(@RequestBody RealNameForm realNameForm) {
        userService.realName(realNameForm, httpServletRequest);
        return RespMsg.success();
    }


    @ApiOperation(
            value = "获取当前实名信息",
            notes = "获取当前实名信息")
    @OperationLogRecord(
            describe = "获取当前实名信息",
            modularCode = "/user/getRealInfo",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    @RequestMapping(
            value = "/getRealInfo",
            method = RequestMethod.GET)
    @CheckRealUser
    public RespMsg getRealInfo() {
        return RespMsg.success(userService.queryCurrentUser(httpServletRequest));
    }
}
